<?php

namespace App\Http\Requests\Admin;

use Illuminate\Foundation\Http\FormRequest;

class ArticleInputDTO extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     * 'groupId', 'name', 'email', 'mobile'
     * @return array
     */
    public function rules()
    {
        return [
            'title' => 'required|max:100',
            'abstract' => 'required|max:500',
            'cover' => 'required|max:500',
            'jump' => 'max:500',
            'video' => 'max:500',
            'tag' => 'max:40',
            'author' => 'max:40',
            'source' => 'max:20',
            'click' => 'numeric',
            'coin' => 'numeric',
            'type_id' => 'required|numeric',
            'content' => 'required'
        ];
    }

    public function messages()
    {
        return [
            'title.required' => '标题不能为空',
            'title.max' => '标题不能超过100个字符',
            'abstract.required' => '摘要不能为空',
            'abstract.max' => '摘要文字过长',
            'type_id.required' => '栏目不能为空',
            'content.required' => '内容不能为空',
            'cover.required' => '封面图片不能为空',
            'cover.max' => '封面图片过大',
        ];
    }
}
